package main

import (
	"encoding/json"
	"fmt"
)

type Student struct {
	Name string `json:"name"`
	Age  int    `json:"age"`
}

type Class struct {
	Title    string    `json:"name"`
	Students []Student `json:"students"`
}

func main() {
	var c = Class{
		Title:    "数学",
		Students: make([]Student, 0),
	}

	for i := range 10 {
		s := Student{
			Name: fmt.Sprintf("student%d", i),
			Age:  i,
		}
		c.Students = append(c.Students, s)
	}

	marshal, _ := json.Marshal(c)
	fmt.Println(string(marshal))
}
